package com.guide.exception;

import com.guide.enums.ErrorCodeEnum;

public class ServiceException extends RuntimeException {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6436715004464332684L;

	private int errorCode;
	private String error;
	private String errorText;

	public ServiceException(ErrorCodeEnum errorCodeEnum, Throwable cause) {
		super(errorCodeEnum.toString(), cause);
		this.errorCode = errorCodeEnum.getErrorCode();
		this.error = errorCodeEnum.getError();
		this.errorText = errorCodeEnum.getErrorText();
	}

	/**
	 * 可定制error_msg
	 * 
	 * @param errorCodeEnum
	 * @param cause
	 * @param error_text
	 *            自定义的error_msg
	 */
	public ServiceException(ErrorCodeEnum errorCodeEnum, Throwable cause,
			String errorText) {
		super(errorCodeEnum.toString() + "  " + errorText, cause);
		this.errorCode = errorCodeEnum.getErrorCode();
		this.error = errorCodeEnum.getError();
		this.errorText = errorText;
	}

	public ServiceException(ErrorCodeEnum errorCodeEnum, String errorText) {
		super(errorCodeEnum.toString() + "  " + errorText);
		this.errorCode = errorCodeEnum.getErrorCode();
		this.error = errorCodeEnum.getError();
		this.errorText = errorCodeEnum.getErrorText() + errorText;
	}

	public ServiceException(ErrorCodeEnum errorCodeEnum) {
		super(errorCodeEnum.toString());
		this.errorCode = errorCodeEnum.getErrorCode();
		this.error = errorCodeEnum.getError();
		this.errorText = errorCodeEnum.getErrorText();
	}

	public int getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getErrorText() {
		return errorText;
	}

	public void setErrorText(String errorText) {
		this.errorText = errorText;
	}

}
